EBI Java Tools and Utils
Version 2.2a

embl.ebi.tools.Regex
Class RegExp

java.lang.Object
  |
  +--embl.ebi.tools.Regex.RegExpCore
        |
        +--embl.ebi.tools.Regex.RegExp

public class RegExp
extends embl.ebi.tools.Regex.RegExpCore

A class that handles basic regular expressions.

This package was written by MAEDA Shugo. The original name of the package is JP.ac.osaka_u.ender.util.regex. Here is the substantial part of the original README file:

    *** Package JP.ac.osaka_u.ender.util.regex ***

    Copyright (C) 1997 MAEDA Shugo
    Version 0.11  Apr. 13, 1997

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation.

    You can get the latest version on my web page.
    URL: http://www.pic-internet.or.jp/user/kojin/ender/

    Reference Books
        Kondo Yoshiyuki, "Alogorithms and Data Structures for C Programers", SOFTBANK BOOKS, 1993
        Ed Tittel, Mark Gaither, "60 Minute Guide to Java", SOFTBANK BOOKS, 1996
        Black Monkey, RegExp.pas Version 0.15 for Delphi2, 1996
 
I have made only the following changes:
Overview
RegExp A class that implements pattern matching with regular expressions
MatchInfo A class that is used in the class RegExp to return patern matching infomations
RegExpSyntaxException Signals that the regular expression is invalid
NFABuildException Signals an exception has occured when building NFA
See TestRegex or Substitutor for examples how to use RegExp.
Supported Regular Expressions
The RegExp class supports the following expressions:
X character itself
XY cocatenation
X|Y selection
X* closure
X+ X|X*
X? X|()
[XYZ] X|Y|Z
[h-n] h|i|j...n
[^XYZ] not [XYZ]
. any one character
^ beginning of string
$ end of string
\0 0
\t tabulator
\r carriage return
\n newline
\d [0-9]
\D [^0-9]
\s [ \t\r\n]
\S [^ \t\r\n]
\w [0-9A-Z_a-z]
\W [^0-9A-Z_a-z]

Version:
0.08, 02/16/97 ($Id: RegExp.java,v 1.2 2000/07/10 14:01:18 senger Exp $)
Author:
Shugo Maeda
See Also:
TestRegex

Constructor Summary
RegExp()
          Constructs a RegExp instance.
RegExp(java.lang.String pattern)
          Constructs a RegExp instance with the specified regular expression.
 
Method Summary
 java.lang.String dfaString()
           
 MatchInfo[] globalMatch(java.lang.String text)
          Global pattern match.
 MatchInfo match(java.lang.String text)
          Pattern match with the current specified regular expression.
 MatchInfo match(java.lang.String text, int begin, int end)
          Pattern match with the current specified regular expreshassion.
 java.lang.String nfaString()
           
 java.lang.String pattern()
           
 void setPattern(java.lang.String pattern)
          Sets the regular expression string.
 java.lang.String[] split(java.lang.String text)
          Splits a text by the matched strings.
 java.lang.String substitute(java.lang.String text, java.lang.String replacement, boolean global)
          Substitutes subText for matched strings.
 java.lang.String toString()
           
 java.lang.String treeString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegExp

public RegExp()
Constructs a RegExp instance.


RegExp

public RegExp(java.lang.String pattern)
       throws RegExpSyntaxException,
              NFABuildException
Constructs a RegExp instance with the specified regular expression.

Method Detail

match

public MatchInfo match(java.lang.String text)
Pattern match with the current specified regular expression.

Parameters:
text - the target text.
Returns:
Returns the information on pattern matching.

match

public MatchInfo match(java.lang.String text,
                       int begin,
                       int end)
Pattern match with the current specified regular expreshassion.

Parameters:
text - the target text.
begin - the begining index for the target.
end - the ending index for the target.
Returns:
Returns the information on pattern matching.

globalMatch

public MatchInfo[] globalMatch(java.lang.String text)
Global pattern match.

Parameters:
text - the target text.
Returns:
Returns Enumeration of MatchInfo.

split

public java.lang.String[] split(java.lang.String text)
Splits a text by the matched strings.

Parameters:
text - the target text.
Returns:
Returns Enumeration of the splited texts.

substitute

public java.lang.String substitute(java.lang.String text,
                                   java.lang.String replacement,
                                   boolean global)
Substitutes subText for matched strings.

Parameters:
text - the target text.
global - if true substitutes for all matched strings.

setPattern

public void setPattern(java.lang.String pattern)
                throws RegExpSyntaxException,
                       NFABuildException
Sets the regular expression string.

Throws:
RegExpSyntaxException - If the regular expression syntax is invalid.
NFABuildException

pattern

public java.lang.String pattern()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

treeString

public java.lang.String treeString()

nfaString

public java.lang.String nfaString()

dfaString

public java.lang.String dfaString()

EBI Java Tools and Utils
Version 2.2a

Submit a bug or feature
Generated: Wed Feb 13 14:59:03 GMT 2002